﻿using System;
using System.Collections.Generic;
using NUnit.Framework;
using SimpleCheckout;

namespace SimpleCheckout.Specs
{
	[TestFixture]
	public class PricingRulesSpec
	{
		[Test]
		public void ShouldNotProvdeAnySpecialPrice_WhenItemIsNotOnSale() {
			Dictionary<string, int> saleRules = new Dictionary<string, int>();
			PricingRules pricingRules = new PricingRules(saleRules);
			pricingRules.LookupPrice("A", 1).Should().Be.EqualTo(null);
		}
		
		[Test]
		public void ShouldNotProvideSpecialPrice_WhenItemIsOnSale_AndNumberOfUnitsDoNotMatchSpecialPriceRule()
		{
			Dictionary<string, int> saleRules = new Dictionary<string, int>();
			saleRules.Add("A:3", 130);
			PricingRules pricingRules = new PricingRules(saleRules);
			
			pricingRules.LookupPrice("A", 1).Should().Be.EqualTo(null);
		}
		
		[Test]
		[TestCase("A", 3, 130)]
		[TestCase("B", 2, 45)]
		public void ShouldProvideSpecialPrice_WhenItemIsOnSale_AndNumberOfUnitsMatchSpecialPriceRule(string sku, int units, int specialPrice)
		{
			Dictionary<string, int> saleRules = new Dictionary<string, int>();
			saleRules.Add(String.Format("{0}:{1}", sku, units), specialPrice);
			PricingRules pricingRules = new PricingRules(saleRules);
			
			pricingRules.LookupPrice(sku, units).Should().Be.EqualTo(specialPrice);
		}
	}
}
